
#include "stdio.h"
#include "rootNode.h"
#include "projector.h"

//#include <google/profiler.h>

#include <omp.h>





int main(int argc, char *argv[]){


	const char* model_path_name = "../../results";
	const char* weight_file_name  = "./ucla_weighting.w";
	char test_file_name[512];
	int batch_id = 0;
//	printf("Tell me the file batch number:");
//	scanf("%d",&batch_id);
	if(batch_id==0){
		sprintf(&test_file_name[0],"./ucla_test_pos_file_list.txt");
	}else{
		sprintf(&test_file_name[0],"./ucla_test_pos_file_list_%d.txt",batch_id);
	}


	rootNode node_root;
	std::vector<int> node_id; 
	for(int i =1; i<=12; ++i)	node_id.push_back(i);
	node_root.initialRootNode(model_path_name,node_id,weight_file_name);

	char img_name[300];
	FILE *p_file = fopen(const_cast<const char*>(&test_file_name[0]),"r");
	if(p_file ==NULL){
		printf("Failed to open file %s \n", test_file_name);
		return -1;
	}

	/*number of files*/
	int n_file;
	fscanf(p_file,"%d\n",&n_file);
	printf("%d files to process\n",n_file);
	for(int i_file = 0; i_file<n_file; ++i_file){
		if(feof(p_file)){
			printf("error: unexpected end of file\n");
			return -1;
		}
		fscanf(p_file,"%s\n",&img_name[0]);
		printf("processing file %s \n",img_name);
		//node_root.detection(img_name);
		node_root.sequentialDetection(img_name);
	}

    node_root.release();

	fclose(p_file);

//	ProfilerStop();
	return 1;
}
